<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
		<title>自定义表单修改字段</title>
		<link rel="stylesheet" href="../static/web/font/css/font-awesome.min.css">
		<link rel="stylesheet" href="../static/web/css/bootstrap.min.css">
		<link rel="stylesheet" href="../static/web/css/admin.css">
		<script src="../static/web/js/jquery.min.js"></script>
		<script src="../static/web/js/bootstrap.min.js"></script>
		<script src="js/main.js"></script>
		<style>.nw{float:left;width:160px}.cls{clear:both}</style>
		<script>
			function GetFields()
			{
				var theform = document.form1;
				var itemname = theform.itemname.value;
				var fieldname = theform.fname.value;
				var dtype = theform.dtype.value;
				var isnull = theform.isnull.value;
				var vdefault = theform.vdefault.value;
				var maxlength = theform.maxlength.value;
				var vinnertext = theform.vinnertext.value;
				var spage = (theform.spage[0].checked ? theform.spage[0].value : theform.spage[1].value);
				var sisnull = (isnull==0 ? "false" : "true");
				if (itemname=="")
				{
					ShowMsg("表单提示名称不能为空");
					theform.itemname.focus();
					return false;
				}
				if ((dtype=="radio"||dtype=="select"||dtype=="checkbox") && vdefault=="")
				{
					ShowMsg("您选择的select或radio、checkbox类型，必须默认值设置选择的项目（用英文逗号）");
					return false;
				}
				if (spage=="no") spage = "";
				revalue =  "<field:"+fieldname+" itemname=\""+itemname+"\" autofield=\"1\" type=\""+dtype+"\"";
				revalue += " isnull=\""+sisnull+"\" default=\""+vdefault+"\" ";
				revalue += " maxlength=\""+maxlength+"\" page=\""+spage+"\">"+vinnertext+"</field:"+fieldname+">";
				document.form1.fieldstring.value = revalue;
				return true;
			}
		</script>
	</head>
	<body>
		<table cellpadding="1" cellspacing="1" align="center" class="table maintable my-3">
			<form name="form1" action="diy_field_edit.php" method="post" onSubmit="return GetFields();">
				<input type="hidden" name="action" value="save">
				<input type="hidden" name="diyid" value="<?php echo $diyid?>">
				<input type="hidden" name="fname" value="<?php echo $fname?>">
				<input type="hidden" name="issystem" value="<?php echo $issystem?>">
				<input type="hidden" name="fieldstring" value="">
				<tr>
					<td bgcolor="#f5f5f5" colspan="2">自定义表单管理</a> &gt; 自定义表单修改字段</td>
				</tr>
				<tr>
					<td>提示文字：</td>
					<td><input type="text" name="itemname" id="itemname" class="admin-input-sm" value="<?php echo $ctag->GetAtt('itemname')?>">（发布文档时显示的项名字）</td>
				</tr>
				<tr>
					<td width="260">字段名称：</td>
					<td><?php echo $fname?>（只能用英文字母或数字，数据表的真实字段名）</td>
				</tr>
				<tr>
					<td>数据类型：</td>
					<td>
						<select name="dtype" id="type" class="admin-input-sm">
							<?php 
							$dtype = $ctag->GetAtt('type');
							if ($dtype!='' && isset($fieldtypes[$dtype]))
							{
								echo "<option value='{$dtype}'>{$fieldtypes[$dtype]}</option>";
								$canchange = true;
							} else {
								echo "<option value='{$dtype}'>系统专用类型</option>";
								$canchange = false;
							}
							if ($canchange)
							{
							?>
							<option value="text">单行文本(varchar)</option>
							<option value="textchar">单行文本(char)</option>
							<option value="multitext">多行文本</option>
							<option value="htmltext">网页文本</option>
							<option value="int">整数类型</option>
							<option value="float">小数类型</option>
							<option value="datetime">时间类型</option>
							<option value="img">图片</option>
							<option value="addon">附件类型</option>
							<option value="select">option下拉框</option>
							<option value="radio">radio选项卡</option>
							<option value="checkbox">checkbox多选框</option>
							<?php }?>
						</select>
					</td>
				</tr>
				<tr>
					<td>文档是否需要分页符：</td>
					<td>
						<input type="hidden" name="isnull" value="1">
						<label><input type="radio" name="spage" value="split" <?php if ($ctag->GetAtt('page')=='split') echo "checked='1'";?>> 是</label>
						<label><input type="radio" name="spage" value="no" <?php if ($ctag->GetAtt('page')=='no'||$ctag->GetAtt('page')=='') echo "checked='1'";?>> 否</label>
						<span>（如果文档需要分页符，不论何种文档，都可以用#P#副标题#e#作为分页符号实现文档分页，但一个模型里仅允许一个这样的字段）</span>
					</td>
				</tr>
				<tr>
					<td>默认值：</td>
					<td>
						<textarea name="vdefault" id="vdefault" class="admin-textarea-xl"><?php echo $ctag->GetAtt('default');?></textarea>
						<span>（如果定义数据类型为select、radio、checkbox时，此处填写被选择的项目，英文逗号分开，如“DedeBIZ,得德”。如果为联动选框，这里填写联动选框项目名称）</span>
					</td>
				</tr>
				<tr>
					<td>最大长度：</td>
					<td><input type="text" name="maxlength" id="maxlength" class="admin-input-xs" value="<?php echo $ctag->GetAtt('maxlength')?>">（文本数据必须填写，大于255为text类型）</td>
				</tr>
				<tr>
					<td>自定义网页表单：</td>
					<td>自定义网页表单用~name~表示提示文字，~form~表示表单元素</td>
				</tr>
				<tr>
					<td align="center"></td>
					<td><textarea name="vinnertext" id="vinnertext" class="admin-textarea-xl"><?php echo $ctag->GetInnerText();?></textarea></td>
				</tr>
				<tr>
					<td bgcolor="#f5f5f5" colspan="2" align="center">
						<button type="submit" class="btn btn-success btn-sm">保存</button>
						<button type="reset" class="btn btn-outline-success btn-sm">重置</button>
					</td>
				</tr>
			</form>
		</table>
	</body>
</html>